<%--
    Document   : heroesForm
    Created on : Nov 23, 2012, 5:59:23 PM
    Author     : newohybat
--%>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<s:form beanclass="cz.muni.fi.pa165.ddtroops.web.actionbeans.HeroActionBean">
    <tiles:importAttribute name="hidden" />
    <s:hidden name="${hidden}"/>
    <fieldset><legend><tiles:getAsString name="legend"/></legend>
    <s:errors/>

    <div id="form">
        <div class="row">
            <s:label for="b1" name="hero.belief"/>
            <s:text id="b1" name="hero.belief"/>
            <div class="accordion">
                <s:label for="requiredValue"/>
            </div>
        </div>

        <div class="row">
            <s:label for="b2" name="hero.biography"/>
            <s:text id="b2" name="hero.biography"/>
            <div class="accordion">
                <s:label for="requiredValue"/>
            </div>
        </div>

        <div class="row">
            <s:label for="b3" name="hero.charisma"/>
            <s:text id="b3" name="hero.charisma"/>
            <div class="accordion">
                <s:label for="requiredValue"/><br/>
                <s:label for="nonnegative"/>
            </div>
        </div>

        <div class="row">
            <s:label for="b4" name="hero.constitution"/>
            <s:text id="b4" name="hero.constitution"/>
            <div class="accordion">
                <s:label for="requiredValue"/><br/>
                <s:label for="nonnegative"/>
            </div>
        </div>

        <div class="row">
            <s:label for="b5" name="hero.dexterity"/>
            <s:text id="b5" name="hero.dexterity"/>
            <div class="accordion">
                <s:label for="requiredValue"/><br/>
                <s:label for="nonnegative"/>
            </div>
        </div>

        <div class="row">
            <s:label for="b6" name="hero.gender"/>
            <s:select name="hero.gender"><s:options-enumeration id="b6" enum="cz.muni.fi.pa165.ddtroops.entities.Gender"/></s:select>
        </div>

        <div class="row">
            <s:label for="b7" name="hero.intelligence"/>
            <s:text id="b7" name="hero.intelligence"/>
            <div class="accordion">
                <s:label for="requiredValue"/><br/>
                <s:label for="nonnegative"/>
            </div>
        </div>

        <div class="row">
            <s:label for="b8" name="hero.name"/>
            <s:text id="b8" name="hero.name"/>
            <div class="accordion">
                <s:label for="requiredValue"/>
            </div>
        </div>

        <div class="row">
            <s:label for="b9" name="hero.profession"/>
            <s:select name="hero.profession" id="b9" >
                <s:options-collection collection="${actionBean.getProffessions()}"/>
            </s:select>
            <div class="accordion">
                <s:label for="requiredValue"/>
            </div>
        </div>

        <div class="row">
            <s:label for="b10" name="hero.strength"/>
            <s:text id="b10" name="hero.strength"/>
            <div class="accordion">
                <s:label for="requiredValue"/><br/>
                <s:label for="nonnegative"/>
            </div>
        </div>

        <div class="row">
            <s:label for="b11" name="hero.wisdom"/>
            <s:text id="b11" name="hero.wisdom"/>
            <div class="accordion">
                <s:label for="requiredValue"/><br/>
                <s:label for="nonnegative"/>
            </div>
        </div>

        <div class="row">
            <s:label for="b12" name="hero.xp"/>
            <s:text id="b12" name="hero.xp"/>
            <div class="accordion">
                <s:label for="requiredValue"/><br/>
                <s:label for="nonnegative"/>
            </div>
        </div>

        <div class="row">
            <s:label for="b13" name="hero.race"/>
            <input type="hidden" id="originalRaceId" value="${actionBean.hero.race.id}"/>
            <s:select name="hero.race" id="b13" >
                <s:options-collection collection="${actionBean.races}" label="name" value="id"/>
            </s:select>
        </div>
            <s:hidden name="hero.owner" value="${actionBean.owner.id}"/>
    </div>

    <tiles:importAttribute name="action" />
    <div class="cent">
    <s:submit name="${action}"><tiles:getAsString name="button"/></s:submit>
    </div>
    </fieldset>
</s:form>

<script type="text/javascript">
    $(document).ready(function(){
        $('#originalRaceId').each(function(key,value){
           $("#b13 option[value="+value.value+"]").attr("selected",true);
        });
    });
</script>